<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
    <!-- Link Swiper's CSS -->
    <link rel="stylesheet" href="../swiper/swiper.min.css">

    <!-- Demo styles -->
    <style>
        html, body {
            position: relative;
            height: 100%;
        }

        body {
            background: #eee;
            font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
            font-size: 14px;
            color: #000;
            margin: 0;
            padding: 0;
        }

        .swiper-container {
            width: 100%;
            height: 100%;

        }

        .swiper-slide {
            text-align: center;
            font-size: 18px;
            background: #fff;

            /* Center slide text vertically */
            display: -webkit-box;
            display: -ms-flexbox;
            display: -webkit-flex;
            display: flex;
            -webkit-box-pack: center;
            -ms-flex-pack: center;
            -webkit-justify-content: center;
            justify-content: center;
            -webkit-box-align: center;
            -ms-flex-align: center;
            -webkit-align-items: center;
            align-items: center;
        }

        .swiper-pagination-bullet {
            width: 30px;
            height: 30px;
        }

        .swiper-container .start-stop-btn {
            position: absolute;
            right: 10px;
            bottom: 10px;
            width: 80px;
            height: 80px;
            cursor: pointer;
            z-index: 999;
        }

        .swiper-container .start-stop-btn a {
            display: inline-block;
            width: 80px;
            height: 80px;
            background: red;
        }
    </style>
</head>
<body>
<!-- Swiper -->
<div class="swiper-container" id="app">
    <div class="swiper-wrapper">
        <div class="swiper-slide" v-for="image in images">
            <img :src="image">
        </div>
    </div>
    <!-- Add Pagination -->
    <div class="swiper-pagination"></div>
    <!-- Add Arrows -->
    <div class="swiper-button-next"></div>
    <div class="swiper-button-prev"></div>
    <div class="start-stop-btn">
        <a class="start-btn" style="background: url('../images/start.png')" v-show="!autoPlay"
           @click="startAutoPlay"></a>
        <a class="pause-btn" style="background: url('../images/pause.png')" v-show="autoPlay"
           @click="stopAutoPlay"></a>
    </div>
</div>

<!-- Swiper JS -->
<script src="../swiper/swiper.min.js"></script>
<script src="../js/vue.min.js"></script>

<!-- Initialize Swiper -->
<script>
    var app = new Vue({
        el: '#app',
        data: {
            swiper: {},
            images: ['../images/02/1.JPG', '../images/02/2.JPG', '../images/02/3.JPG'],
            autoPlay: true
        },
        methods: {
            startAutoPlay: function () {
                //开启自动播放
                var _this = this;
                _this.autoPlay = true;
                console.log(_this);
                _this.swiper.startAutoplay();
            },
            stopAutoPlay: function () {
                //关闭自动播放
                var _this = this;
                _this.autoPlay = false;
                console.log(_this);
                _this.swiper.stopAutoplay();
            }

        },
        mounted: function () {
            var _this = this;
            _this.swiper = new Swiper('.swiper-container', {
                pagination: '.swiper-pagination',
                nextButton: '.swiper-button-next',
                prevButton: '.swiper-button-prev',
                paginationClickable: true,
                spaceBetween: 30,
                centeredSlides: true,
                autoplay: 7000,
                autoplayDisableOnInteraction: false,
                loop: true
            });
        }
    })
</script>
</body>
</html>